<!--
 * Description: 估价驳回功能
 * Company: 联宝（合肥）电子科技有限公司
 * Author:Chengming.Li
 * Date: 2021/01/06 16:28
-->

<template>
  <div>
    <!--数据表单-->
    <el-form label-width="120px" :model="formData" size="mini">
      <el-row>
        <!--FD RowID-->
        <el-col :span="24">
          <el-form-item label="Row ID">
            <span>{{ formData.fdRowId, }}</span>
          </el-form-item>
        </el-col>

        <!--FD 编号-->
        <el-col :span="24">
          <el-form-item :label="$t('FdData.fdId')">
            <span>{{ taskData.fdId }}</span>
          </el-form-item>
        </el-col>

        <!--FD version-->
        <el-col :span="24">
          <el-form-item :label="$t('FdData.version')">
            <span>{{ taskData.version }}</span>
          </el-form-item>
        </el-col>
        <!--gcmCostRemark-->
        <el-col :span="24">
          <el-form-item class="long-label" :label="$t('FdData.rejectRemark')">
            <el-input v-model="formData.gcmCostRemark" clearable :rows="2" type="textarea" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span style="display: block;text-align: center;margin-top: 5px">
      <!--取消按钮-->
      <el-button size="medium" @click="cancel">{{ $t('button.cancel') }}</el-button>
      <!--保存按钮-->
      <el-button size="medium" type="primary" @click="save">{{ $t('button.save') }}</el-button>
    </span>
  </div>
</template>

<script>
import { fdRowRejectToIdp } from '@/api/quote/fd-row'

export default {
  name: 'EcEvaluationEditForward',
  props: {
    inputData: {
      type: Object,
      default() {
        return {}
      }
    },
    taskData: {
      type: Object,
      default: () => null
    }
  },
  data() {
    return {
      formData: {}
    }
  },
  computed: {},
  created() {
    this.pageDataInit()
  },
  methods: {
    pageDataInit() {
      // 将props传入的值复制给formData的值
      this.formData = this.$deepCopy(this.inputData)
    },
    async save() {
      try {
        await fdRowRejectToIdp(
          {
            fdId: this.taskData.fdId,
            fdRowId: this.formData.fdRowId,
            version: this.taskData.version,
            gcmCostRemark: this.formData.gcmCostRemark
          },
          { msgSuccess: true, msgError: true }
        )
        this.$emit('save', this.formData)
      } catch (error) {
        console.log(error)
      }
    },
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>

<style lang="scss" scoped>
.el-form-item__content span {
  margin-left: 5px;
  color: blue;
}
</style>
